#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstring>
using namespace std;
class CString
{
private:
	char* s_data;
	int s_length;
public:
	CString():s_data(nullptr),s_length(0)
	{}
	CString(const char* temp) :s_data(nullptr), s_length(0)
	{
		if (temp) {
			int n = strlen(temp);
			s_data = new char[n + 1];
			strcpy(s_data, temp);
			s_length = n;
		}
	}
	CString(const CString& temp) :s_data(nullptr), s_length(0)
	{
		if (temp.s_data) {
			int n = temp.s_length;
			s_data = new char[n + 1];
			strcpy(s_data, temp.s_data);
			s_length = n;
		}
	}
	CString& operator=(const CString& temp)
	{
		if (this != &temp)
		{
			if (s_data) {
				delete[] s_data;
			}
			int n = temp.s_length;
			if (temp.s_data) {
				s_data = new char[n + 1];
			}
			strcpy(s_data, temp.s_data);
			s_length = n;
		}
		return *this;
	}
	CString& operator=(CString&& temp) noexcept
	{
		if (this != &temp)
		{
			if (s_data) {
				delete[] s_data;
			}
			s_data = temp.s_data;
			s_length = temp.s_length;
			temp.s_length = 0;
			temp.s_data = nullptr;
		}
		return *this;
	}

	~CString()
	{
		if (s_data) {
			delete[] s_data;
			s_length = 0;
		}
	}
	int length()
	{
		return s_length;
	}
};
int main()
{
	CString s("chenbiaoren");
	CString s2 = s;
	cout << s2.length() << endl;
	return 0;
}